<?php
require_once 'DBClass.php';
class DBUnit extends PHPUnit_Framework_TestCase{
	private static $dbh;
	public static function setUpBeforeClass(){
		global $db;
		self::$dbh=$db;
	}
	public function testConnect(){
		$this->assertNotEmpty(self::$dbh);
	}
	//Provide to test correct SQL Script
	public function correct_data(){
		return array(
		array("select * from ndtl_list")
		);
	}
	/**
	 *  @dataProvider correct_data
	 */
	public function testCorrectSQL($sql){
		$this->assertNotEmpty(self::$dbh->sql_query($sql));
		return $sql;
	}
	//Provide to test failure SQL Script
	public function failure_data(){
		return array(
		array("select * from failure_list"),
		array("select * from not_table")
		);
	}
	/**
	 * @dataProvider failure_data
	 * @expectedException PHPUnit_Framework_Error
	 */
	public function testFailureSQL($sql){
		$this->assertEmpty(self::$dbh->sql_query($sql));
	}
	/**
	 * @dataProvider correct_data
	 */
	public function testReturnSQLList($sql){
		$this->assertType('array',self::$dbh->sql_list($sql));
	}
}
?>